<%--
  Created by IntelliJ IDEA.
  User: Colorful
  Date: 2023/8/16
  Time: 19:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="path" value="${pageContext.request.contextPath }"/>
<html>
<head>
    <title>个人信息</title>
    <script rel="script" src="${path}/js/jquery-3.6.4.js"></script>
    <link rel="stylesheet" type="text/css" href="${path}/css/userProfile.css">
</head>
<body>
<c:set var="industryList" value="${sessionScope.industryList}"/>
<c:set var="userAll" value="${requestScope.userAll}"/>
<c:choose>
    <c:when test="${empty industryList}">
        <script>
            window.location="${path}/IndustryServlet?prom=insShow";
        </script>
    </c:when>
    <c:when test="${empty userAll}">
        <script>
            window.location="${path}/UserServlet?prom=selUser&user_id=${sessionScope.user.user_id}";
        </script>
    </c:when>
    <c:otherwise>
        <div class="profile-container">
            <div class="profile-title">基本信息</div>
            <div class="avatar-container">
                <div class="avatar-content">
                    <img id="userImage" name="userImage" src="${path}/images/userAvatar/${userAll.image}">
                    <div class="J-upload-avatar-w upload-avatar-image">
                        <input type="button" class="J-upload-avatar upload-btn" value="更换头像">
                    </div>
                </div>
                <div class="tips">支持JPG,JPEG,PNG格式,且文件需小于1M</div>
            </div>
<%--            id="fileUpload"--%>
            <form id="J-userexinfo-form" class="userexinfo-form" enctype="multipart/form-data"  method="post" action="${path}/UserServlet?prom=updUser&user_id=6">
                <input type="file" id="fileUpload" STYLE="opacity: 0;position: absolute;left: 72px;bottom: 196px; font-size: 43px!important;width: 182px;"  name="file" value="${userAll.image}">
                <div class="userexinfo-form-section">
                    <p>昵称：</p>
                    <span>
                <input type="text" name="nickName" id="userexinfo-form-nickname" class="ui-checkbox" placeholder="2-15个字，支持中英文、数字" value="${userAll.userName}">
            </span>
                </div>
                <div class="userexinfo-form-section">
                    <p>性别：</p>
                    <c:if test="${userAll.sex==1}">
                        <span><input type="radio" name="gender" class="ui-radio radio-first" value="1" checked>男</span>
                        <span><input type="radio" name="gender" class="ui-radio" value="2">女</span>
                    </c:if>
                    <c:if test="${userAll.sex==2}">
                        <span><input type="radio" name="gender" class="ui-radio radio-first" value="1">男</span>
                        <span><input type="radio" name="gender" class="ui-radio"  value="2" checked>女</span>
                    </c:if>
                </div>
                <div class="date-picker userexinfo-form-section ">
                    <p>生日：</p>
                    <span><input type="date" name="birth" value="${userAll.birth}" class="ui-birth"></span>
                </div>
                <div class="userexinfo-form-section">
                    <p>生活状态：</p>
                    <c:if test="${userAll.status==1}">
                        <span><input type="radio" name="status" class="ui-radio" value="1" checked>单身 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="2">热恋中 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="3">已婚 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="4">为人父母 </span>
                    </c:if>
                    <c:if test="${userAll.status==2}">
                        <span><input type="radio" name="status" class="ui-radio" value="1" >单身 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="2" checked>热恋中 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="3">已婚 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="4">为人父母 </span>
                    </c:if>
                    <c:if test="${userAll.status==3}">
                        <span><input type="radio" name="status" class="ui-radio" value="1" >单身 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="2">热恋中 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="3" checked>已婚 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="4">为人父母 </span>
                    </c:if>
                    <c:if test="${userAll.status==4}">
                        <span><input type="radio" name="status" class="ui-radio" value="1" >单身 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="2">热恋中 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="3">已婚 </span>
                        <span><input type="radio" name="status" class="ui-radio" value="4" checked>为人父母 </span>
                    </c:if>
                </div>
                <div class="userexinfo-form-section">
                    <P>从行事业：</P>
                    <span>
                <select class="selIns" name="ind_name" value="">
                    <c:forEach var="il" items="${industryList}">
                        <option>${il.ind_name}</option>
                    </c:forEach>
                </select>
            </span>
                </div>
                <div class="userexinfo-form-section expand-list">
                    <p>兴趣：</p>
                    <span><input type="text" name="interest" value="${userAll.interest}" placeholder="请输入你的兴趣爱好"></span>
                </div>
                <div class="userexinfo-form-section">
                    <P>个性签名：</P>
                    <span><input type="text" name="signature" value="${userAll.signature}" placeholder="20个字以内"></span>
                </div>
                <div class="userexinfo-bottom-section clearfix">
                    <input  type="submit" class="form-save-btn" value="保存">
                </div>
            </form>
        </div>
    </c:otherwise>
</c:choose>
<script>
    $("#fileUpload").change(function () {
        //获取文件名称
        var url=document.getElementById('fileUpload').files[0].name;
            $("#userImage").attr("src","${path}/images/userAvatar/"+url);
    })
</script>
</body>
</html>
